home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -serious- / programming / basic / mildred / lha / bounce9.lha / Bounce9.ascii < prev    next >
Text File  |  1999-03-07  |  15KB  |  507 lines

  1. WBStartup
  2.  
  3. .Variables
  4.  
  5. CPUminimum.b=Processor
  6. PrefDisplayDepth.w=8
  7. *ScrVP._ViewPort=0
  8. IsAGA.b=False
  9. Multitasking.b=True ; Default
  10. Dim PlanarBuf.l(2) ; Base address of planar memory to output c2p to (allowed up to triple buffers)
  11.  
  12. .Prefs
  13.  
  14. PrefDisplayID.l=$0 ; Default (unspecified, as it may possibly retarget (doublescan etc))
  15. ;PrefDisplayID.l=$21000 ; AGA Lores PAL 320x256 non-laced single-scan 50Hz
  16. ;PrefDisplayID.l=$A1000 ; AGA Lores DoublePAL 384x275 non-laced double-scan 48Hz
  17. ;PrefDisplayID.l=$89000 ; AGA Lores Super72 384x290 non-laced single-scan 71Hz
  18. ;PrefDisplayID.l=$11000 ; AGA Lores NTSC 320x200 non-laced single-scan 60Hz
  19. ;PrefDisplayID.l=$39000 ; AGA Lores Multiscan 320x240 double-scan 58Hz
  20. ;PrefDisplayID.l=$59000 ; AGA Lores HighGFX 512x250 non-laced single-scan 54Hz
  21. ;PrefDisplayID.l=$69000 ; AGA Lores Euro72 320x200 non-laced double-scan 69Hz
  22. ;PrefDisplayID.l=$91000 ; AGA Lores DoubleNTSC 384x227 non-laced double-scan 58Hz
  23. ;PrefDisplayID.l=$29004 ; AGA PAL 640x400 Hires laced single-scan 50Hz
  24. ;PrefDisplayID.l=$19004 ; AGA NTSC 640x400 Hires laced single-scan 60Hz
  25. ;PrefDisplayID.l=$39024 ; AGA Multiscan 640x400 Hires non-laced single-scan 58Hz
  26. ;PrefDisplayID.l=$69024 ; AGA Euro72 640x400 Hires non-laced single-scan 69Hz
  27. ;PrefDisplayID.l=$A9004 ; AGA DoublePAL 640x400 Hires non-laced double-scan 48Hz
  28. ;PrefDisplayID.l=$99004 ; AGA DoubleNTSC 640x400 Hires non-laced double-scan 58Hz
  29. PrefDisplayWidth.w=320
  30. PrefDisplayHeight.w=240
  31. PrefDisplayBuffering.b=1 ; 1..3
  32. ;If Joyb(0)=0 AND Joyb(1)=0 Then Goto PrefsSkip
  33.  
  34. #DTAG_DISP=$80000000
  35. #DTAG_DIMS=$80001000
  36. #DTAG_MNTR=$80002000
  37. #DTAG_NAME=$80003000
  38.  
  39. NEWTYPE.SMode
  40.   DID.l
  41.   DWidth.l
  42.   DHeight.l
  43.   DDepth.w
  44.   DType.w
  45. End NEWTYPE
  46.  
  47. DEFTYPE.Hook myhook ; The hook for ASL tag as &myhook
  48. myhook\h_Entry=?hook
  49. MOVE.l a5,globalbase
  50. funcret.l=0
  51.  
  52. Dim SMRtags.TagItem(17)
  53. SMRtags(0)\ti_Tag=#ASLSM_InitialLeftEdge,160
  54. SMRtags(1)\ti_Tag=#ASLSM_InitialTopEdge,0
  55. SMRtags(2)\ti_Tag=#ASLSM_InitialWidth,300
  56. SMRtags(3)\ti_Tag=#ASLSM_InitialHeight,600
  57. SMRtags(4)\ti_Tag=#ASLSM_InitialDisplayID,$21000
  58. SMRtags(5)\ti_Tag=#ASLSM_InitialDisplayDepth,8
  59. SMRtags(6)\ti_Tag=#ASLSM_InitialDisplayWidth,PrefDisplayWidth
  60. SMRtags(7)\ti_Tag=#ASLSM_InitialDisplayHeight,PrefDisplayHeight
  61. SMRtags(8)\ti_Tag=#ASLSM_InitialOverscanType,1
  62. SMRtags(9)\ti_Tag=#ASLSM_InitialInfoOpened,1
  63. SMRtags(10)\ti_Tag=#ASLSM_InitialInfoLeftEdge,350
  64. SMRtags(11)\ti_Tag=#ASLSM_InitialInfoTopEdge,50
  65. SMRtags(12)\ti_Tag=#ASLSM_DoDepth,0
  66. SMRtags(13)\ti_Tag=#ASLSM_DoOverscanType,1
  67. SMRtags(14)\ti_Tag=#ASLSM_DoWidth,1
  68. SMRtags(15)\ti_Tag=#ASLSM_DoHeight,1
  69. SMRtags(16)\ti_Tag=#ASLSM_FilterFunc,&myhook
  70. SMRtags(17)\ti_Tag=#TAG_DONE,0
  71.  
  72. *sreq.SMode=0
  73. *sreq=AllocAslRequest_(2,&SMRtags(0)\ti_Tag)
  74. ok.b=AslRequest_(*sreq,&SMRtags(0)\ti_Tag)
  75.  
  76. If ok<>0
  77.   PrefDisplayID.l=*sreq\DID
  78.   PrefDisplayWidth.w=*sreq\DWidth
  79.   PrefDisplayHeight.w=*sreq\DHeight
  80. EndIf
  81. If (*sreq) Then FreeAslRequest_(*sreq)
  82.  
  83. Goto PrefsSkip
  84.  
  85. ;*************************************************************************
  86. ; This is the statement that the hook will call.  Put the label before
  87. ; the statement you want to jump to.
  88. Runerrsoff
  89. .hook_jump:
  90. Statement hook{*dahook.Hook, modeID.l, *smr.ScreenModeRequester}
  91.   ; We're inside the hook, and supposedly we should be able to do whatever
  92.   ; we want.
  93.   ; Filter modeID's here
  94.   SHARED funcret.l
  95.   DEFTYPE.DisplayInfo DisInfoBuf
  96.   DEFTYPE.DimensionInfo DimInfoBuf
  97.   DEFTYPE.MonitorInfo MonInfoBuf
  98.   DEFTYPE.NameInfo NamInfoBuf
  99.   ;Refer to Includes/Graphics/DisplayInfo.h or view newtypes
  100.   IDhandle.l=FindDisplayInfo_(modeID)
  101.   GetDisplayInfoData_ IDhandle,&DisInfoBuf,SizeOf.DisplayInfo,#DTAG_DISP,0
  102.   GetDisplayInfoData_ IDhandle,&DimInfoBuf,SizeOf.DimensionInfo,#DTAG_DIMS,0
  103.   GetDisplayInfoData_ IDhandle,&MonInfoBuf,SizeOf.MonitorInfo,#DTAG_MNTR,0
  104.   GetDisplayInfoData_ IDhandle,&NamInfoBuf,SizeOf.NameInfo,#DTAG_NAME,0
  105.   ;Do tests. True=Mode is valid, False=mode is invalid.
  106.   If DimInfoBuf\MaxDepth<>8
  107.     ;No true-colour modes, only 8-bit
  108.     funcret=False
  109.   Else
  110.     funcret=True
  111.   EndIf
  112. End Statement
  113.  
  114. ;**********************
  115. ; Hook
  116. Macro goto_hook
  117.   JSR `1+6
  118. End Macro
  119.  
  120. globalbase: Dc.l 0
  121.  
  122. hook: ;This hook is called by the filter hook callback from screenmode requester, per item
  123. ; Store registers
  124. MOVEM.l   d1-d7/a0-a6,-(a7) ; Not d0!
  125.  
  126. ; Put parameters into dregs ready for a statement
  127. MOVE.l    a0,d0
  128. MOVE.l    a1,d1
  129. MOVE.l    a2,d2
  130.  
  131. ; Get global variable base
  132. MOVE.l    globalbase,a5
  133.  
  134. ; Goto hook statement
  135. !goto_hook{hook_jump}
  136.  
  137. GetReg d0,funcret ; return accept/discard
  138.  
  139. ; Restore registers
  140. MOVEM.l   (a7)+,d1-d7/a0-a6 ; Not d0!
  141.  
  142. RTS
  143. ;**********************
  144.  
  145. Runerrson
  146. PrefsSkip
  147.  
  148. .Display
  149.  
  150. Statement Permit{}
  151. ;Permit multitasking, only if it is globally intended
  152.   SHARED Multitasking.b
  153.   If Multitasking Then Permit_
  154. End Statement
  155.  
  156. Statement Forbid{}
  157. ;Disable multitasking, if it isn't globally intended
  158.   SHARED Multitasking.b
  159.   If Multitasking Then Forbid_
  160. End Statement
  161.  
  162. Statement Multitasking{State.b}
  163. ;Toggle global multitasking on or off.
  164.   SHARED Multitasking.b
  165.   If State
  166.     If Multitasking=False Then Permit_
  167.   Else
  168.     If Multitasking Then Forbid_
  169.   EndIf
  170.   Multitasking=State
  171. End Statement
  172.  
  173. Function.b InitDisplay{Title$}
  174. ;Creates a display
  175. ;Title$=The screen title (not displayed)
  176.   SHARED PrefDisplayHeight.w,PrefDisplayID.l,PrefDisplayBuffering.b,*ScrVP._ViewPort,IsAGA.b
  177.   SHARED PrefDisplayLeft.w,PrefDisplayTop.w
  178.   SHARED PrefDisplayDepth.w,PrefDisplayWidth.w,CPUminimum.b
  179.   SHARED PlanarBuf()
  180.   ;Open a test screen first to a) test for AGA or GFX-Card, and b) because the dimensions might be
  181.   ;too large to open a chipram screen, and the dimensions for AGA have not yet been reduced to within limits
  182.   Dim ScrTags.TagItem(13)
  183.   Rect.Rectangle\MinX=0,0,320,240 ; For test
  184.   ScrTags(0)\ti_Tag=#SA_Width,320 ; For test
  185.   ScrTags(1)\ti_Tag=#SA_Height,240; For test
  186.   ScrTags(2)\ti_Tag=#SA_Depth,PrefDisplayDepth
  187.   ScrTags(3)\ti_Tag=#SA_DisplayID,PrefDisplayID
  188.   ScrTags(4)\ti_Tag=#SA_Type,$F
  189.   ScrTags(5)\ti_Tag=#SA_Quiet,True
  190.   ScrTags(6)\ti_Tag=#SA_ShowTitle,False
  191.   ScrTags(7)\ti_Tag=#SA_Behind,True
  192.   ScrTags(8)\ti_Tag=#SA_DClip,&Rect ; For test
  193.   ScrTags(9)\ti_Tag=#SA_Exclusive,False
  194.   ScrTags(10)\ti_Tag=#SA_Draggable,True
  195.   ScrTags(11)\ti_Tag=#SA_AutoScroll,True
  196.   ScrTags(12)\ti_Tag=#TAG_DONE,0
  197.   ScrTags(13)\ti_Tag=#TAG_DONE,0
  198.   UsedChip.l=(320 LSR 3)*PrefDisplayDepth*240 ; With test params
  199.   FreeChip.l=AvailMem_(#MEMF_CHIP)
  200.   Forbid{}
  201.   If ScreenTags(0,Title$,&ScrTags(0))<>0 ; Test for GFX-Card or AGA
  202.     NowChip.l=AvailMem_(#MEMF_CHIP)
  203.     Permit{}
  204.     If FreeChip-NowChip<UsedChip
  205.       ; Graphics card screen
  206.       IsAGA=False
  207.       PrefDisplayWidth AND $FFF0 ; For gfx-cards, width to nearest 16
  208.       ScrTags(0)\ti_Tag=#SA_Width,PrefDisplayWidth
  209.       Rect.Rectangle\MinX=0,0,PrefDisplayWidth,PrefDisplayHeight
  210.       ScrTags(1)\ti_Tag=#SA_Height,PrefDisplayHeight*PrefDisplayBuffering
  211.       ScrTags(8)\ti_Tag=#SA_DClip,&Rect
  212.       VWait 5 ; seems to be necessary (safer)
  213.       Free Screen 0
  214.       VWait 5 ; just to be on the safe side
  215.       If ScreenTags(0,Title$,&ScrTags(0))<>0
  216.         For Loop.w=0 To PrefDisplayBuffering-1
  217.           If Loop=0 Then WFlags.l=$1900 Else WFlags.l=$800
  218. If Window(Loop,0,PrefDisplayHeight*Loop,PrefDisplayWidth,PrefDisplayHeight,WFlags,"",0,0)=0 Then Function Return False
  219.           Menus Off
  220.           ScreensBitMap 0,Loop
  221.           *TmpBmp.bitmap=Addr BitMap(Loop)
  222.           Offset.l=*TmpBmp\_ebwidth*(PrefDisplayHeight*Loop)
  223.           For DLoop.w=0 To PrefDisplayDepth-1
  224.             *TmpBmp\_data[DLoop]=*TmpBmp\_data[DLoop]+Offset
  225.           Next DLoop
  226.         Next Loop
  227.       Else
  228.         Function Return False
  229.       EndIf
  230.     Else
  231.       ; AGA screen
  232.       IsAGA=True
  233.       PrefDisplayWidth AND $FFC0 ; For AGA, width to nearest 64
  234.       ScrTags(0)\ti_Tag=#SA_Width,PrefDisplayWidth
  235.       Rect.Rectangle\MinX=0,0,PrefDisplayWidth,PrefDisplayHeight
  236.       ScrTags(1)\ti_Tag=#SA_Height,PrefDisplayHeight ; Seperate buffers
  237.       ScrTags(8)\ti_Tag=#SA_DClip,&Rect
  238.       ScrTags(3)\ti_Tag=#SA_DisplayID,PrefDisplayID
  239.       Forbid{}
  240.       VWait 5 ; seems to be necessary (safer)
  241.       Free Screen 0
  242.       For Loop.w=0 To PrefDisplayBuffering-1
  243.         If Loop=0 Then WFlags.l=$1900 Else WFlags.l=$800
  244.         If AvailMem_(#MEMF_CHIP)>=(PrefDisplayWidth*PrefDisplayHeight)+16
  245.           Memory.l=AllocMem((PrefDisplayWidth*PrefDisplayHeight)+16,$10002) ; Chip bitmap
  246.           Memory=(Memory+16) AND $FFFFFFF0 ; Align for move16's
  247.           If Memory<>0
  248.             CludgeBitMap Loop,PrefDisplayWidth,PrefDisplayHeight,PrefDisplayDepth,Memory
  249.             If Loop=0
  250.               ScrTags(12)\ti_Tag=#SA_BitMap,Addr BitMap(0)
  251.               If ScreenTags(0,Title$,&ScrTags(0))=0
  252.                 Permit{}
  253.                 Function Return False
  254.               EndIf
  255.             EndIf
  256.             If Window(Loop,0,0,PrefDisplayWidth,PrefDisplayHeight,WFlags,"",0,0)=0 Then Function Return False
  257.             Menus Off
  258.           Else
  259.             Permit{}
  260.             Function Return False
  261.           EndIf
  262.         Else
  263.           Permit{}
  264.           Function Return False
  265.         EndIf
  266.         PlanarBuf(Loop)=Memory
  267.       Next Loop
  268.       Permit{}
  269.     EndIf
  270.     DEFTYPE.DimensionInfo DimInfoBuf
  271.     GetDisplayInfoData_ FindDisplayInfo_(PrefDisplayID) AND $FFFFFFFF,&DimInfoBuf,SizeOf.DimensionInfo,#DTAG_DIMS,0
  272.     PrefDisplayLeft.w=((DimInfoBuf\TxtOScan\MaxX)-PrefDisplayWidth)/2
  273.     PrefDisplayTop.w=((DimInfoBuf\TxtOScan\MaxY)-PrefDisplayHeight)/2
  274.     *Scr._Screen=Peek.l(Addr Screen(0))
  275.     *ScrVP=ViewPort(0)
  276.     *ScrVP\DxOffset=PrefDisplayLeft,PrefDisplayTop
  277.     ScrollVPort_ *ScrVP
  278.     RethinkDisplay_
  279.     Use Palette 0
  280.     Menus Off
  281.     If *ScrVP\DHeight<>PrefDisplayHeight
  282.       Forbid{}
  283.       *Scr\Height=PrefDisplayHeight ; Enforce y clipping
  284.       Permit{}
  285.     EndIf
  286.     ScreenToFront_ *Scr
  287.     Function Return True
  288.   Else
  289.     Permit{}
  290.     Function Return False
  291.   EndIf
  292. End Function
  293.  
  294. .Main
  295.  
  296. Pic$="5Ms.IFF"
  297.  
  298. #Objects=30
  299. #UnQ=-1 ; Wether or not to unqueue the objects
  300.  
  301. ;Init
  302. MCPU CPUminimum        ; The two most important
  303. Mc2pCPUmode CPUminimum ; lines in your program!
  304.  
  305. Mc2pWindow 0,PrefDisplayWidth,PrefDisplayHeight
  306.  
  307. InitBank 0,PrefDisplayWidth*PrefDisplayHeight,$10000
  308. CludgeBitMap 0,PrefDisplayWidth,PrefDisplayHeight,8,Bank(0)
  309. InitPalette 0,256
  310. LoadBitMap 0,Pic$,0
  311.  
  312. ;Make a chunky shape
  313. If MShape(0,64,64)=0 Then End
  314. MPlanar16ToShape 0,Bank(0),64,64,PrefDisplayWidth,PrefDisplayHeight
  315. MMakeCookie 0
  316.  
  317. s=1
  318. For y=0 To 32 Step 32
  319.   For x=0 To 32 Step 32
  320.     If MShape(s,32,32)=0 Then End
  321.     MPlanar16ToShape s,Bank(0)+((PrefDisplayWidth/8)*y)+(x/8)+(64/8),32,32,PrefDisplayWidth,PrefDisplayHeight
  322.     MMakeCookie s
  323.     s+1
  324.   Next x
  325. Next y
  326.  
  327. Free Bank 0
  328.  
  329. .Move
  330. ;Set up movement tables
  331. Dim x.w(#Objects)
  332. Dim y.w(#Objects)
  333. Dim xdirection.b(#Objects)
  334. Dim ydirection.b(#Objects)
  335. Dim xdirectionswap.b(#Objects)
  336. Dim ydirectionswap.b(#Objects)
  337. For obj=1 To #Objects
  338.   x(obj)=Rnd(PrefDisplayWidth-48)+16
  339.   y(obj)=Rnd(PrefDisplayHeight-48)+16
  340.   Repeat
  341.     xdirection(obj)=Rnd(8)-4
  342.   Until xdirection(obj)<>0
  343.   Repeat
  344.     ydirection(obj)=Rnd(8)-4
  345.   Until ydirection(obj)<>0
  346.   xdirectionswap(obj)=-xdirection(obj)
  347.   ydirectionswap(obj)=-ydirection(obj)
  348. Next obj
  349.  
  350. .Prepare
  351. If InitDisplay{"Game"}=False Then Goto Finish
  352. ShowPalette 0
  353. Multitasking{On}
  354. If MBitmap(1,PrefDisplayWidth,PrefDisplayHeight)=0 Then End
  355. MAutoStencil On
  356.  
  357. If MBitmap(0,PrefDisplayWidth,PrefDisplayHeight)=0 Then End
  358. *RP._RastPort=RastPort(0)
  359. MCludgeBitmap 4,PrefDisplayWidth,PrefDisplayHeight*PrefDisplayBuffering,*RP\_BitMap\Planes
  360. MUseBitmap 0
  361.  
  362. MUseShape 0
  363. MClsStencil 0
  364. For yy=0 To PrefDisplayHeight-64 Step 64
  365.   For xx=0 To PrefDisplayWidth-64 Step 64
  366.     MSBlock xx,yy
  367.   Next xx
  368. Next yy
  369. MUseBitmap 1
  370. MBlockScroll 0,0,PrefDisplayWidth,PrefDisplayHeight,0,0,0
  371. MUseBitmap 0
  372.  
  373. MQSBlitCut On
  374. MSBlitCut On
  375. MQueue 0,#Objects
  376.  
  377. .Table
  378. VWait 5
  379. MTable 0,256*256
  380. If ReadFile(0,"Bounce.Table")=0 Then Goto Finish
  381. ReadMem 0,MTablePtr,256*256
  382. CloseFile 0
  383. ;Dim R(256),G(256),B(256)
  384. ;PaletteInfo 0
  385. ;For c=0 To 255
  386. ;  R(c)=AGAPalRed(c)
  387. ;  G(c)=AGAPalGreen(c)
  388. ;  B(c)=AGAPalBlue(c)
  389. ;Next c
  390. ;TP.l=MTablePtr
  391. ;For SourceColour=0 To 255
  392. ;  For DestColour=0 To 255
  393. ;    Offset.l=(SourceColour LSL 8)+DestColour
  394. ;    If SourceColour>0 ; only change pixels within the shape
  395. ;      R0=(R(SourceColour)*0.2)+(R(DestColour)*0.8)
  396. ;      G0=(G(SourceColour)*0.2)+(G(DestColour)*0.8)
  397. ;      B0=(B(SourceColour)*0.2)+(B(DestColour)*0.8)
  398. ;      ;R0=Max((R(SourceColour)-R(DestColour)),0)
  399. ;      ;G0=Max((G(SourceColour)-G(DestColour)),0)
  400. ;      ;B0=Max((B(SourceColour)-B(DestColour)),0)
  401. ;      ;R0=R(DestColour)*0.8
  402. ;      ;G0=G(DestColour)*0.8
  403. ;      ;B0=B(DestColour)*0.8
  404. ;    Else ; leave pixels of colour 0 as background
  405. ;      R0=R(DestColour)
  406. ;      G0=G(DestColour)
  407. ;      B0=B(DestColour)
  408. ;    EndIf
  409. ;    Best=0
  410. ;    BestTotal.l=$0FFFFFFF
  411. ;    For TestColour=0 To 255
  412. ;      R1=R(TestColour)
  413. ;      G1=G(TestColour)
  414. ;      B1=B(TestColour)
  415. ;      Total.l=((R0-R1)*(R0-R1))+((G0-G1)*(G0-G1))+((B0-B1)*(B0-B1))
  416. ;      If Abs(Total)<BestTotal
  417. ;        Best=TestColour
  418. ;        BestTotal=Abs(Total)
  419. ;      EndIf
  420. ;    Next TestColour
  421. ;    Poke.b TP+Offset,Best
  422. ;  Next DestColour
  423. ;Next SourceColour
  424. ;;*** runtime ***
  425. ;;Save Off the generated table here
  426. ;If WriteFile(0,"Bounce.Table2")=False Then Goto Finish
  427. ;WriteMem 0,MTablePtr,256*256
  428. ;CloseFile 0
  429.  
  430. MBlitMode MReMapMode
  431. MQBlitMode MReMapMode
  432. MSBlitMode MReMapMode
  433. MQSBlitMode MReMapMode
  434.  
  435. .Loop
  436. buf.b=0
  437. its.l=0
  438. *Ras.RasInfo=*ScrVP\RasInfo
  439. ResetTimer
  440. While Joyb(0)=0 AND Joyb(1)=0
  441.  
  442.   For obj=1 To #Objects
  443.  
  444.     ;Move
  445.     x(obj)+xdirection(obj)
  446.     If x(obj)<4 OR x(obj)>PrefDisplayWidth-36 Then Exchange xdirection(obj),xdirectionswap(obj)
  447.     y(obj)+ydirection(obj)
  448.     If y(obj)<4 OR y(obj)>PrefDisplayHeight-36 Then Exchange ydirection(obj),ydirectionswap(obj)
  449.  
  450.     ;Try changing this to a different type of blit. If it's not a Q-type blit, comment-out the unqueue line also
  451.     MQBlit (obj MOD 4)+1,x(obj),y(obj) ; Stencil-cut blit and add to queue
  452.  
  453.   Next obj
  454.  
  455.   ;Display
  456.   If IsAGA
  457.     ShowBitMap buf
  458.     If PrefDisplayBuffering>1
  459.       buf+1
  460.       If buf=PrefDisplayBuffering Then buf=0
  461.     EndIf
  462.     Mc2p MBitmapPtr(buf),PlanarBuf(buf)
  463.   Else
  464.     *ScrVP\DyOffset=-buf*PrefDisplayHeight
  465. ;    *Ras\RyOffset=buf*PrefDisplayHeight
  466.     ScrollVPort_ *ScrVP
  467. ;    *RP._RastPort=RastPort(buf)
  468. ;    WritePixelArray8_ *RP,0,0,PrefDisplayWidth-1,PrefDisplayHeight-1,MBitmapPtr(0),0
  469.     If PrefDisplayBuffering>1
  470.       buf+1
  471.       If buf=PrefDisplayBuffering Then buf=0
  472.     EndIf
  473. MUseBitmap 4
  474. MBlockScroll 0,0,PrefDisplayWidth,PrefDisplayHeight,0,PrefDisplayHeight*buf,0
  475. MUseBitmap 0
  476.   EndIf
  477.  
  478.   ;Comment this line out if not using a queued blit
  479.   If #UnQ
  480. MUnQueue 0,1
  481.   EndIf
  482. ;  MFlushQueue 0
  483.  
  484.   its+1
  485. Wend
  486.  
  487. ;Report
  488. t=Timer
  489. t=Max(t,1)
  490. its=Max(its,1)
  491. a.q=50.0/(t/its)
  492. WBenchToFront_
  493. FindScreen 1
  494. Window 2,16,16,300,40,0,"Test results",1,0
  495. WindowOutput 2
  496. NPrint a," frames per second"
  497. NPrint " "
  498. NPrint "Press mouse/joy button..."
  499. Repeat
  500. Until Joyb(0)<>0 OR Joyb(1)<>0
  501.  
  502. Finish:
  503. Multitasking{On}
  504. End
  505.  
  506.  
  507.